package Iterator;

/**
 * @Grup:Iterator
 * @Auther:cola
 * @Data:2021/3/29-2021-03-23:21
 * @version:1.0
 *
 */
public class ConcreteIterator  implements Iterators {
    private MyList list=null;
    private int index;//迭代器的下标

    public ConcreteIterator(MyList list) {
        this.list = list;
    }

    @Override
    public boolean hashNext() {
        if ((index>=list.getSize())){
            return false;
        }else return true;
    }

    @Override
    public Object next() {
        Object obj=list.get(index);
        index++;
        return obj;
    }
}
